package com.atguigu.day13.work;

public class Husband extends Thread{
    private Account account;

    public Husband(Account account) {
        this.account = account;
    }

    @Override
    public void run() {
        while (true){
            synchronized (Thread.class){
                double money=Math.random()*10000;
                System.out.println("丈夫存钱,账户状态:"+account);
                System.out.println("丈夫本次存钱:"+money);
                account.setBalance(account.getBalance()+money);
                System.out.println("丈夫存钱结束,账户状态:"+account);
                System.out.println();
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                Thread.class.notify();
            }
        }
    }
}
